package org.offsync.async

import scala.util.parsing.input.Position

abstract class AsyncReader[+T] {
  def source: java.lang.CharSequence = throw new NoSuchMethodError("not a char sequence reader")

  def offset: Int = throw new NoSuchMethodError("not a char sequence reader")

  def first: T

  def rest: AsyncReader[T]
  
  def drop(n: Int): AsyncReader[T] = {
    var r: AsyncReader[T] = this
    var cnt = n
    while (cnt > 0) {
      r = r.rest; cnt -= 1
    }
    r
  }

  /** The position of the first element in the reader
   */
  def pos: Position

  /** true iff there are no more elements in this reader 
   */
  def atEnd: Boolean
}
